#tag Class
Protected Class OccupyActionState
Implements PlayerActionStates
	#tag Method, Flags = &h0
		Function ToString() As String
		  return "OccupyActionState"
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Function GetNextTile() As Tile
		  return nil
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub Constructor(p as Player)
		  player = p
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Function AddTileAtPosition(newTile as Tile, position as Coordinates) As boolean
		  return false
		End Function
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub RotateClockwise()
		  //nothing happens here
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub RotateCounterclockwise()
		  //nothing happens here
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub Occupy(s as string)
		  dim pos as string
		  dim success as boolean = false
		  
		  
		  if player.HasGamepieces then
		    pos = player.GetGame.GetCurrentTile.SlotWizard(s)
		    
		    select case pos
		    case "nw"
		      success = player.GetGame.GetCurrentTile.GetNorthWestSlot.PlaceGamepiece(player.GetGamepiece)
		    case "n"
		      success = player.GetGame.GetCurrentTile.GetNorthSlot.PlaceGamepiece(player.GetGamepiece)
		    case "ne"
		      success = player.GetGame.GetCurrentTile.GetNorthEastSlot.PlaceGamepiece(player.GetGamepiece)
		    case "w"
		      success =player.GetGame.GetCurrentTile.GetWestSlot.PlaceGamepiece(player.GetGamepiece)
		    case "c"
		      success =player.GetGame.GetCurrentTile.GetCentreSlot.PlaceGamepiece(player.GetGamepiece)
		    case "e"
		      success = player.GetGame.GetCurrentTile.GetEastSlot.PlaceGamepiece(player.GetGamepiece)
		    case "sw"
		      success = player.GetGame.GetCurrentTile.GetSouthWestSlot.PlaceGamepiece(player.GetGamepiece)
		    case "s"
		      success = player.GetGame.GetCurrentTile.GetSouthSlot.PlaceGamepiece(player.GetGamepiece)
		    case "se"
		      success = player.GetGame.GetCurrentTile.GetSouthEastSlot.PlaceGamepiece(player.GetGamepiece)
		    end select
		    
		    if success = false then
		      msgbox "something went wrong: (" + pos + ")"
		    end if
		    
		    #if DebugBuild
		      's´MsgBox player.GetGame.GetCurrentTile.GetUid
		    #endif
		    
		    
		    player.GetGame.Update
		    player.NextPhase
		  end if
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub CalculateScore()
		  //nothing happens
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub EndRound()
		  player.NextPhase
		  player.EndRound
		End Sub
	#tag EndMethod


	#tag Property, Flags = &h21
		Private player As Player
	#tag EndProperty


	#tag ViewBehavior
		#tag ViewProperty
			Name="Name"
			Visible=true
			Group="ID"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Index"
			Visible=true
			Group="ID"
			InitialValue="-2147483648"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Super"
			Visible=true
			Group="ID"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Left"
			Visible=true
			Group="Position"
			InitialValue="0"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Top"
			Visible=true
			Group="Position"
			InitialValue="0"
			InheritedFrom="Object"
		#tag EndViewProperty
	#tag EndViewBehavior
End Class
#tag EndClass
